class data:
    def __del__(self):
        print("del data")


class a:
    def __init__(self):
        self.data = data()
        self.chhildren = []

    def add_child(self, child):
        self.chhildren.append(child)
        child.parent = self

    def __del__(self):
        # pass
        del self.data
        del self.chhildren

b = a()
b.add_child(a())

